From daa70e9d6e2679efde2d42592dce08b603f00f8a Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 12 Nov 2009 11:59:18 +0000 Subject: [PATCH] x86: Remove non-CONFIG_HOTPLUG_CPU code, and general cleanup. Signed-off-by: Keir Fraser --- xen/arch/x86/cpu/common.c | 2 - xen/arch/x86/irq.c | 32 +++---- xen/arch/x86/setup.c | 4 - xen/arch/x86/smpboot.c | 192 +++++++++++++++----------------------- xen/include/asm-x86/smp.h | 7 -- 5 files changed, 92 insertions(+), 145 deletions(-) diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c index b1bf521712..bc6e051daf 100644 --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -615,10 +615,8 @@ void __cpuinit cpu_init(void) #undef CD } -#ifdef CONFIG_HOTPLUG_CPU void __cpuinit cpu_uninit(void) { int cpu = raw_smp_processor_id(); cpu_clear(cpu, cpu_initialized); } -#endif diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index 30d223bea5..222b9c62ea 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -1638,10 +1639,6 @@ static int __init setup_dump_irqs(void) } __initcall(setup_dump_irqs); -#ifdef CONFIG_HOTPLUG_CPU -#include -#include - /* A cpu has been removed from cpu_online_mask. Re-set irq affinities. */ void fixup_irqs(void) { @@ -1650,19 +1647,23 @@ void fixup_irqs(void) struct irq_desc *desc; irq_guest_action_t *action; struct pending_eoi *peoi; - for(irq = 0; irq < nr_irqs; irq++ ) { + + for ( irq = 0; irq < nr_irqs; irq++ ) + { int break_affinity = 0; int set_affinity = 1; cpumask_t affinity; - if (irq == 2) + + if ( irq == 2 ) continue; + desc = irq_to_desc(irq); - /* interrupt's are disabled at this point */ + spin_lock(&desc->lock); affinity = desc->affinity; - if (!desc->action || - cpus_equal(affinity, cpu_online_map)) { + if ( !desc->action || cpus_equal(affinity, cpu_online_map) ) + { spin_unlock(&desc->lock); continue; } @@ -1674,22 +1675,22 @@ void fixup_irqs(void) affinity = cpu_online_map; } - if (desc->handler->disable) + if ( desc->handler->disable ) desc->handler->disable(irq); - if (desc->handler->set_affinity) + if ( desc->handler->set_affinity ) desc->handler->set_affinity(irq, affinity); - else if (!(warned++)) + else if ( !(warned++) ) set_affinity = 0; - if (desc->handler->enable) + if ( desc->handler->enable ) desc->handler->enable(irq); spin_unlock(&desc->lock); - if (break_affinity && set_affinity) + if ( break_affinity && set_affinity ) printk("Broke affinity for irq %i\n", irq); - else if (!set_affinity) + else if ( !set_affinity ) printk("Cannot set affinity for irq %i\n", irq); } @@ -1714,4 +1715,3 @@ void fixup_irqs(void) peoi[sp].ready = 1; flush_ready_eoi(); } -#endif diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index a8d254027e..98249807bc 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -484,10 +484,6 @@ void __init __start_xen(unsigned long mbi_p) smp_prepare_boot_cpu(); -#ifdef CONFIG_HOTPLUG_CPU - prefill_possible_map(); -#endif - /* We initialise the serial devices very early so we can get debugging. */ ns16550.io_base = 0x3f8; ns16550.irq = 4; diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 024896fa4a..87972146be 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -58,7 +58,6 @@ #include #include -#define set_kernel_exec(x, y) (0) #define setup_trampoline() (bootsym_phys(trampoline_realmode_entry)) /* Set if we find a B stepping CPU */ @@ -82,7 +81,7 @@ EXPORT_SYMBOL(cpu_online_map); cpumask_t cpu_callin_map; cpumask_t cpu_callout_map; EXPORT_SYMBOL(cpu_callout_map); -cpumask_t cpu_possible_map; +cpumask_t cpu_possible_map = CPU_MASK_ALL; EXPORT_SYMBOL(cpu_possible_map); static cpumask_t smp_commenced_mask; @@ -491,8 +490,8 @@ void __devinit start_secondary(void *unused) set_processor_id(cpu); set_current(idle_vcpu[cpu]); this_cpu(curr_vcpu) = idle_vcpu[cpu]; - if ( cpu_has_efer ) - rdmsrl(MSR_EFER, this_cpu(efer)); + if ( cpu_has_efer ) + rdmsrl(MSR_EFER, this_cpu(efer)); asm volatile ( "mov %%cr4,%0" : "=r" (this_cpu(cr4)) ); percpu_traps_init(); @@ -521,11 +520,11 @@ void __devinit start_secondary(void *unused) set_cpu_sibling_map(raw_smp_processor_id()); wmb(); - /* Initlize vector_irq for BSPs */ - lock_vector_lock(); - __setup_vector_irq(smp_processor_id()); + /* Initlize vector_irq for BSPs */ + lock_vector_lock(); + __setup_vector_irq(smp_processor_id()); cpu_set(smp_processor_id(), cpu_online_map); - unlock_vector_lock(); + unlock_vector_lock(); per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; @@ -767,10 +766,8 @@ wakeup_secondary_cpu(int phys_apicid, unsigned long start_eip) do { Dprintk("+"); udelay(100); - if ( !x2apic_enabled ) - send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY; - else - send_status = 0; /* We go out of the loop dirctly. */ + send_status = (x2apic_enabled ? 0 : + apic_read(APIC_ICR) & APIC_ICR_BUSY); } while (send_status && (timeout++ < 1000)); /* @@ -837,7 +834,7 @@ static int __devinit do_boot_cpu(int apicid, int cpu) struct vcpu *v; struct desc_struct *gdt; #ifdef __x86_64__ - struct page_info *page; + struct page_info *page; #endif /* @@ -963,11 +960,11 @@ static int __devinit do_boot_cpu(int apicid, int cpu) cpu_clear(cpu, cpu_initialized); /* was set by cpu_init() */ cpucount--; - /* Mark the CPU as non-present */ - spin_lock(&cpu_add_remove_lock); + /* Mark the CPU as non-present */ + spin_lock(&cpu_add_remove_lock); x86_cpu_to_apicid[cpu] = BAD_APICID; cpu_clear(cpu, cpu_present_map); - spin_unlock(&cpu_add_remove_lock); + spin_unlock(&cpu_add_remove_lock); } else { } @@ -978,7 +975,6 @@ static int __devinit do_boot_cpu(int apicid, int cpu) return boot_error; } -#ifdef CONFIG_HOTPLUG_CPU static void idle_task_exit(void) { /* Give up lazy state borrowed by this idle vcpu */ @@ -1021,7 +1017,6 @@ static int __cpuinit __smp_prepare_cpu(int cpu) exit: return ret; } -#endif /* * Cycle through the processors sending APIC IPIs to boot each. @@ -1120,8 +1115,8 @@ static void __init smp_boot_cpus(unsigned int max_cpus) kicked = 1; - for_each_present_cpu ( cpu ) - { + for_each_present_cpu ( cpu ) + { apicid = x86_cpu_to_apicid[cpu]; /* @@ -1130,11 +1125,11 @@ static void __init smp_boot_cpus(unsigned int max_cpus) if ((apicid == boot_cpu_apicid) || (apicid == BAD_APICID)) continue; - if (!check_apicid_present(apicid)) - { - dprintk(XENLOG_WARNING, "Present CPU has valid apicid\n"); + if (!check_apicid_present(apicid)) { + dprintk(XENLOG_WARNING, + "Present CPU has valid apicid\n"); continue; - } + } if (max_cpus <= cpucount+1) continue; @@ -1233,7 +1228,6 @@ void __devinit smp_prepare_boot_cpu(void) per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; } -#ifdef CONFIG_HOTPLUG_CPU static void remove_siblinginfo(int cpu) { @@ -1318,7 +1312,7 @@ void __cpu_die(unsigned int cpu) static int take_cpu_down(void *unused) { - return __cpu_disable(); + return __cpu_disable(); } int cpu_down(unsigned int cpu) @@ -1357,8 +1351,8 @@ int cpu_down(unsigned int cpu) cpu_mcheck_distribute_cmci(); out: - if (!err) - send_guest_global_virq(dom0, VIRQ_PCPU_STATE); + if (!err) + send_guest_global_virq(dom0, VIRQ_PCPU_STATE); spin_unlock(&cpu_add_remove_lock); return err; } @@ -1379,8 +1373,8 @@ int cpu_up(unsigned int cpu) goto out; out: - if (!err) - send_guest_global_virq(dom0, VIRQ_PCPU_STATE); + if (!err) + send_guest_global_virq(dom0, VIRQ_PCPU_STATE); spin_unlock(&cpu_add_remove_lock); return err; } @@ -1436,99 +1430,72 @@ void enable_nonboot_cpus(void) smpboot_restore_warm_reset_vector(); } -int prefill_possible_map(void) -{ - int i; - - for (i = 0; i < NR_CPUS; i++) - cpu_set(i, cpu_possible_map); - return 0; -} - int cpu_add(uint32_t apic_id, uint32_t acpi_id, uint32_t pxm) { - int cpu = -1; + int cpu = -1; #ifndef CONFIG_ACPI - return -ENOSYS; + return -ENOSYS; #endif - dprintk(XENLOG_DEBUG, "cpu_add apic_id %x acpi_id %x pxm %x\n", - apic_id, acpi_id, pxm); + dprintk(XENLOG_DEBUG, "cpu_add apic_id %x acpi_id %x pxm %x\n", + apic_id, acpi_id, pxm); - if ( acpi_id > MAX_MADT_ENTRIES || apic_id > MAX_APICS || pxm > 256 ) - return -EINVAL; + if ( acpi_id > MAX_MADT_ENTRIES || apic_id > MAX_APICS || pxm > 256 ) + return -EINVAL; - /* Detect if the cpu has been added before */ - if ( x86_acpiid_to_apicid[acpi_id] != 0xff) - { - if (x86_acpiid_to_apicid[acpi_id] != apic_id) - return -EINVAL; - else - return -EEXIST; - } + /* Detect if the cpu has been added before */ + if ( x86_acpiid_to_apicid[acpi_id] != 0xff) + { + if (x86_acpiid_to_apicid[acpi_id] != apic_id) + return -EINVAL; + else + return -EEXIST; + } - if ( physid_isset(apic_id, phys_cpu_present_map) ) - return -EEXIST; + if ( physid_isset(apic_id, phys_cpu_present_map) ) + return -EEXIST; spin_lock(&cpu_add_remove_lock); - cpu = mp_register_lapic(apic_id, 1); - - if (cpu < 0) - { - spin_unlock(&cpu_add_remove_lock); - return cpu; - } - - x86_acpiid_to_apicid[acpi_id] = apic_id; - - if ( !srat_disabled() ) - { - int node; - - node = setup_node(pxm); - if (node < 0) - { - dprintk(XENLOG_WARNING, "Setup node failed for pxm %x\n", pxm); - x86_acpiid_to_apicid[acpi_id] = 0xff; - mp_unregister_lapic(apic_id, cpu); - spin_unlock(&cpu_add_remove_lock); - return node; - } - apicid_to_node[apic_id] = node; - } - - srat_detect_node(cpu); - numa_add_cpu(cpu); - spin_unlock(&cpu_add_remove_lock); - dprintk(XENLOG_INFO, "Add CPU %x with index %x\n", apic_id, cpu); - return cpu; -} + cpu = mp_register_lapic(apic_id, 1); + if (cpu < 0) + { + spin_unlock(&cpu_add_remove_lock); + return cpu; + } -#else /* ... !CONFIG_HOTPLUG_CPU */ -int __cpu_disable(void) -{ - return -ENOSYS; -} + x86_acpiid_to_apicid[acpi_id] = apic_id; + + if ( !srat_disabled() ) + { + int node; + + node = setup_node(pxm); + if (node < 0) + { + dprintk(XENLOG_WARNING, + "Setup node failed for pxm %x\n", pxm); + x86_acpiid_to_apicid[acpi_id] = 0xff; + mp_unregister_lapic(apic_id, cpu); + spin_unlock(&cpu_add_remove_lock); + return node; + } + apicid_to_node[apic_id] = node; + } -void __cpu_die(unsigned int cpu) -{ - /* We said "no" in __cpu_disable */ - BUG(); + srat_detect_node(cpu); + numa_add_cpu(cpu); + spin_unlock(&cpu_add_remove_lock); + dprintk(XENLOG_INFO, "Add CPU %x with index %x\n", apic_id, cpu); + return cpu; } -int cpu_add(uint32_t apic_id, uint32_t acpi_id, uint32_t pxm) -{ - return -ENOSYS; -} -#endif /* CONFIG_HOTPLUG_CPU */ int __devinit __cpu_up(unsigned int cpu) { -#ifdef CONFIG_HOTPLUG_CPU - int ret=0; + int ret = 0; /* * We do warm boot only on cpus that had booted earlier @@ -1543,7 +1510,6 @@ int __devinit __cpu_up(unsigned int cpu) if (ret) return -EIO; -#endif /* In case one didn't come up */ if (!cpu_isset(cpu, cpu_callin_map)) { @@ -1573,12 +1539,6 @@ void __init smp_cpus_done(unsigned int max_cpus) #endif mtrr_save_state(); mtrr_aps_sync_end(); -#ifndef CONFIG_HOTPLUG_CPU - /* - * Disable executability of the SMP trampoline: - */ - set_kernel_exec((unsigned long)trampoline_base, trampoline_exec); -#endif } void __init smp_intr_init(void) @@ -1598,14 +1558,14 @@ void __init smp_intr_init(void) for (seridx = 0; seridx < 2; seridx++) { if ((irq = serial_irq(seridx)) < 0) continue; - irq_vector[irq] = FIRST_HIPRIORITY_VECTOR + seridx + 1; - per_cpu(vector_irq, cpu)[FIRST_HIPRIORITY_VECTOR + seridx + 1] = irq; - irq_cfg[irq].vector = FIRST_HIPRIORITY_VECTOR + seridx + 1; - irq_cfg[irq].domain = (cpumask_t)CPU_MASK_ALL; + irq_vector[irq] = FIRST_HIPRIORITY_VECTOR + seridx + 1; + per_cpu(vector_irq, cpu)[FIRST_HIPRIORITY_VECTOR + seridx + 1] = irq; + irq_cfg[irq].vector = FIRST_HIPRIORITY_VECTOR + seridx + 1; + irq_cfg[irq].domain = (cpumask_t)CPU_MASK_ALL; } - /* IPI for cleanuping vectors after irq move */ - set_intr_gate(IRQ_MOVE_CLEANUP_VECTOR, irq_move_cleanup_interrupt); + /* IPI for cleanuping vectors after irq move */ + set_intr_gate(IRQ_MOVE_CLEANUP_VECTOR, irq_move_cleanup_interrupt); /* IPI for event checking. */ set_intr_gate(EVENT_CHECK_VECTOR, event_check_interrupt); diff --git a/xen/include/asm-x86/smp.h b/xen/include/asm-x86/smp.h index 515cc9a1e0..6f5200dbed 100644 --- a/xen/include/asm-x86/smp.h +++ b/xen/include/asm-x86/smp.h @@ -58,7 +58,6 @@ extern u32 cpu_2_logical_apicid[]; DECLARE_PER_CPU(int, cpu_state); extern spinlock_t(cpu_add_remove_lock); -#ifdef CONFIG_HOTPLUG_CPU #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu)) extern int cpu_down(unsigned int cpu); extern int cpu_up(unsigned int cpu); @@ -66,13 +65,7 @@ extern void cpu_exit_clear(void); extern void cpu_uninit(void); extern void disable_nonboot_cpus(void); extern void enable_nonboot_cpus(void); -int prefill_possible_map(void); int cpu_add(uint32_t apic_id, uint32_t acpi_id, uint32_t pxm); -#else -static inline int cpu_is_offline(int cpu) {return 0;} -static inline void disable_nonboot_cpus(void) {} -static inline void enable_nonboot_cpus(void) {} -#endif /* * This function is needed by all SMP systems. It must _always_ be valid -- 2.30.2